package projet;

import java.io.Serializable;
import java.util.Date;
import java.util.concurrent.TimeUnit;

public class Location implements Serializable
{

	/**
	 * 
	 */
	private static final long serialVersionUID = 1L;

	public LocationId id;
	private int duree_Enjours;
	private int tarif;

	public LocationId getId()
	{
		return id;
	}

	public void setId(LocationId id)
	{
		this.id = id;
	}

	public static long getDateDiff(Date date1, Date date2, TimeUnit timeUnit)
	{
		long diffInMillies = date2.getTime() - date1.getTime();
		System.out.println("GET DATE DIFF");
		System.out.println(timeUnit.convert(diffInMillies,
				TimeUnit.MILLISECONDS));
		return timeUnit.convert(diffInMillies, TimeUnit.MILLISECONDS);
	}

	public Location()
	{
	}

	public int getDuree_enjours()
	{
		return duree_Enjours;
	}

	public void setDuree_enjours(int duree_Enjours)
	{
		this.duree_Enjours = duree_Enjours;
	}

	public int getTarif()
	{
		return tarif;
	}

	public void setTarif(int tarif)
	{
		this.tarif = tarif;
	}

	public boolean equals(Location loc)
	{
		if (this == loc)
			return true;
		if (!(loc instanceof Location))
			return false;

		final Location l = (Location) loc;
		if (!l.getId().equals(getId()))
			return false;
		if (!(l.getDuree_enjours() == (getDuree_enjours())))
			return false;
		if (!(l.getTarif() == (getTarif())))
			return false;
		return true;
	}

	public int hashCode()
	{
		return id.hashCode() * 37;
	}

	public String toString()
	{
		return "\n******************" + "\nPersonne : "
				+ this.id.getPersonne().toString() + "\nVoiture : "
				+ this.id.getVoiture().toString() + "\nDate depart : "
				+ this.id.getDate_depart() + "\nDate fin : "
				+ this.id.getDate_fin() + "\nDuree en jours : "
				+ this.getDuree_enjours() + "\nTarif : " + this.getTarif()
				+ "\n******************";
	}

}